from dataclasses import dataclass
from typing import Optional, List


@dataclass
class User:
    """用户数据模型"""
    id: str
    name: str
    email: Optional[str] = None
    mobile: Optional[str] = None
    department_id: Optional[str] = None
    role_ids: Optional[List[str]] = None
    status: Optional[str] = None

    @classmethod
    def from_dict(cls, data: dict) -> 'User':
        """从字典创建用户对象"""
        return cls(
            id=data.get('id', ''),
            name=data.get('name', ''),
            email=data.get('email'),
            mobile=data.get('mobile'),
            department_id=data.get('departmentId'),
            role_ids=data.get('roleIds', []),
            status=data.get('status')
        )